package com.linkhub.oms.common.enums.logistic;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.linkhub.oms.common.enums.IEnumConvert;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.apache.commons.lang3.StringUtils;

import java.util.Objects;

/**
 * @Description: CountryCodeMappingEnum
 * @Author: echo
 * @Date: 2024/5/30 11:22
 * @Version: 1.0
 */
@Getter
@AllArgsConstructor
public enum CountryCodeMappingEnum implements IEnumConvert<String> {

    AF("Afghanistan","阿富汗","AF"),
    AL("Albania","阿尔巴尼亚","AL"),
    DZ("Algeria","阿尔及利亚","DZ"),
    AS("American Samoa","美属萨摩亚","AS"),
    AD("Andorra","安道尔","AD"),
    AO("Angola","安哥拉","AO"),
    AI("Anguilla","安圭拉","AI"),
    AQ("Antarctica","南极洲","AQ"),
    AG("Antigua and Barbuda","安提瓜和巴布达","AG"),
    AR("Argentina","阿根廷","AR"),
    AM("Armenia","亚美尼亚","AM"),
    AW("Aruba","阿鲁巴","AW"),
    AU("Australia","澳大利亚","AU"),
    AT("Austria","奥地利","AT"),
    AZ("Azerbaijan","阿塞拜疆","AZ"),
    BS("Bahamas","巴哈马","BS"),
    BH("Bahrain","巴林","BH"),
    BD("Bangladesh","孟加拉国","BD"),
    BB("Barbados","巴巴多斯","BB"),
    BY("Belarus","白俄罗斯","BY"),
    BE("Belgium","比利时","BE"),
    BZ("Belize","伯利兹","BZ"),
    BJ("Benin","贝宁","BJ"),
    BM("Bermuda","百慕大","BM"),
    BT("Bhutan","不丹","BT"),
    BO("Bolivia (Plurinational State of)","玻利维亚","BO"),
    BA("Bosnia and Herzegovina","波黑","BA"),
    BW("Botswana","博茨瓦纳","BW"),
    BV("Bouvet Island","布韦岛","BV"),
    BR("Brazil","巴西","BR"),
    IO("British Indian Ocean Territory","英属印度洋领地","IO"),
    VG("Virgin Islands (British)","英属维尔京群岛","VG"),
    BN("Brunei Darussalam","文莱","BN"),
    BG("Bulgaria","保加利亚","BG"),
    BF("Burkina Faso","布基纳法索","BF"),
    MM("Myanmar","缅甸","MM"),
    BI("Burundi","布隆迪","BI"),
    CV("Cabo Verde","佛得角","CV"),
    KH("Cambodia","柬埔寨","KH"),
    CM("Cameroon","喀麦隆","CM"),
    CA("Canada","加拿大","CA"),
    KY("Cayman Islands","开曼群岛","KY"),
    CF("Central African Republic","中非","CF"),
    TD("Chad","乍得","TD"),
    CL("Chile","智利","CL"),
    CN("China","中华人民共和国","CN"),
    CX("Christmas Island","圣诞岛","CX"),
    CC("Cocos (Keeling) Islands","科科斯（基林）群岛","CC"),
    CO("Colombia","哥伦比亚","CO"),
    KM("Comoros","科摩罗","KM"),
    CD("Congo (Democratic Republic of the)","刚果民主共和国","CD"),
    CG("Congo","刚果共和国","CG"),
    CK("Cook Islands","库克群岛","CK"),
    CR("Costa Rica","哥斯达黎加","CR"),
    CI("Côte d'Ivoire","科特迪瓦","CI"),
    HR("Croatia","克罗地亚","HR"),
    CU("Cuba","古巴","CU"),
    CW("Curaçao","库拉索","CW"),
    CY("Cyprus","塞浦路斯","CY"),
    CZ("Czechia","捷克","CZ"),
    DK("Denmark","丹麦","DK"),
    DJ("Djibouti","吉布提","DJ"),
    DM("Dominica","多米尼克","DM"),
    DO("Dominican Republic","多米尼加","DO"),
    EC("Ecuador","厄瓜多尔","EC"),
    EG("Egypt","埃及","EG"),
    SV("El Salvador","萨尔瓦多","SV"),
    GQ("Equatorial Guinea","赤道几内亚","GQ"),
    ER("Eritrea","厄立特里亚","ER"),
    EE("Estonia","爱沙尼亚","EE"),
    ET("Ethiopia","埃塞俄比亚","ET"),
    FK("Falkland Islands (Malvinas)","福克兰群岛","FK"),
    FO("Faroe Islands","法罗群岛","FO"),
    FJ("Fiji","斐济","FJ"),
    FI("Finland","芬兰","FI"),
    FR("France","法国","FR"),
    FX("Metropolitan France","法国本土","FX"),
    GF("French Guiana","法属圭亚那","GF"),
    PF("French Polynesia","法属波利尼西亚","PF"),
    TF("French Southern Territories","法属南部和南极领地","TF"),
    GA("Gabon","加蓬","GA"),
    GM("Gambia","冈比亚","GM"),
    PS("Palestine, State of","巴勒斯坦","PS"),
    GE("Georgia","格鲁吉亚","GE"),
    DE("Germany","德国","DE"),
    GH("Ghana","加纳","GH"),
    GI("Gibraltar","直布罗陀","GI"),
    GR("Greece","希腊","GR"),
    GL("Greenland","格陵兰","GL"),
    GD("Grenada","格林纳达","GD"),
    GP("Guadeloupe","瓜德罗普","GP"),
    GU("Guam","关岛","GU"),
    GT("Guatemala","危地马拉","GT"),
    GG("Guernsey","根西","GG"),
    GN("Guinea","几内亚","GN"),
    GW("Guinea-Bissau","几内亚比绍","GW"),
    GY("Guyana","圭亚那","GY"),
    HT("Haiti","海地","HT"),
    HM("Heard Island and McDonald Islands","赫德岛和麦克唐纳群岛","HM"),
    VA("Holy See","梵蒂冈","VA"),
    HN("Honduras","洪都拉斯","HN"),
    HK("Hong Kong","香港","HK"),
    HU("Hungary","匈牙利","HU"),
    IS("Iceland","冰岛","IS"),
    IN("India","印度","IN"),
    ID("Indonesia","印度尼西亚","ID"),
    IR("Iran (Islamic Republic of)","伊朗","IR"),
    IQ("Iraq","伊拉克","IQ"),
    IE("Ireland","爱尔兰","IE"),
    IM("Isle of Man","马恩岛","IM"),
    IL("Israel","以色列","IL"),
    IT("Italy","意大利","IT"),
    JM("Jamaica","牙买加","JM"),
    JP("Japan","日本","JP"),
    JE("Jersey","泽西","JE"),
    JO("Jordan","约旦","JO"),
    KZ("Kazakhstan","哈萨克斯坦","KZ"),
    KE("Kenya","肯尼亚","KE"),
    KI("Kiribati","基里巴斯","KI"),
    KP("Korea (Democratic People's Republic of)","朝鲜","KP"),
    KR("Korea (Republic of)","韩国","KR"),
    XK("Kosovo","科索沃","XK"),
    KW("Kuwait","科威特","KW"),
    KG("Kyrgyzstan","吉尔吉斯斯坦","KG"),
    LA("Lao People's Democratic Republic","老挝","LA"),
    LV("Latvia","拉脱维亚","LV"),
    LB("Lebanon","黎巴嫩","LB"),
    LS("Lesotho","莱索托","LS"),
    LR("Liberia","利比里亚","LR"),
    LY("Libya","利比亚","LY"),
    LI("Liechtenstein","列支敦士登","LI"),
    LT("Lithuania","立陶宛","LT"),
    LU("Luxembourg","卢森堡","LU"),
    MO("Macao","澳门","MO"),
    MK("North Macedonia","北马其顿","MK"),
    MG("Madagascar","马达加斯加","MG"),
    MW("Malawi","马拉维","MW"),
    MY("Malaysia","马来西亚","MY"),
    MV("Maldives","马尔代夫","MV"),
    ML("Mali","马里","ML"),
    MT("Malta","马耳他","MT"),
    MH("Marshall Islands","马绍尔群岛","MH"),
    MQ("Martinique","马提尼克","MQ"),
    MR("Mauritania","毛里塔尼亚","MR"),
    MU("Mauritius","毛里求斯","MU"),
    YT("Mayotte","马约特","YT"),
    MX("Mexico","墨西哥","MX"),
    FM("Micronesia (Federated States of)","密克罗尼西亚联邦","FM"),
    MD("Moldova (Republic of)","摩尔多瓦","MD"),
    MC("Monaco","摩纳哥","MC"),
    MN("Mongolia","蒙古","MN"),
    ME("Montenegro","黑山","ME"),
    MS("Montserrat","蒙特塞拉特","MS"),
    MA("Morocco","摩洛哥","MA"),
    MZ("Mozambique","莫桑比克","MZ"),
    NA("Namibia","纳米比亚","NA"),
    NR("Nauru","瑙鲁","NR"),
    NP("Nepal","尼泊尔","NP"),
    NL("Netherlands","荷兰","NL"),
    AN("Netherlands Antilles","荷属安的列斯","AN"),
    NC("New Caledonia","新喀里多尼亚","NC"),
    NZ("New Zealand","新西兰","NZ"),
    NI("Nicaragua","尼加拉瓜","NI"),
    NE("Niger","尼日尔","NE"),
    NG("Nigeria","尼日利亚","NG"),
    NU("Niue","纽埃","NU"),
    NF("Norfolk Island","诺福克岛","NF"),
    MP("Northern Mariana Islands","北马里亚纳群岛","MP"),
    NO("Norway","挪威","NO"),
    OM("Oman","阿曼","OM"),
    PK("Pakistan","巴基斯坦","PK"),
    PW("Palau","帕劳","PW"),
    PA("Panama","巴拿马","PA"),
    PG("Papua New Guinea","巴布亚新几内亚","PG"),
    PY("Paraguay","巴拉圭","PY"),
    PE("Peru","秘鲁","PE"),
    PH("Philippines","菲律宾","PH"),
    PN("Pitcairn","皮特凯恩群岛","PN"),
    PL("Poland","波兰","PL"),
    PT("Portugal","葡萄牙","PT"),
    PR("Puerto Rico","波尔图黎各","PR"),
    QA("Qatar","卡塔尔","QA"),
    RE("Réunion","留尼汪","RE"),
    RO("Romania","罗马尼亚","RO"),
    TW("Taiwan, Province of China[note 1]","台湾","TW"),
    RU("Russian Federation","俄罗斯","RU"),
    RW("Rwanda","卢旺达","RW"),
    BL("Saint Barthélemy","圣巴泰勒米","BL"),
    SH("Saint Helena, Ascension and Tristan da Cunha","圣赫勒拿、阿森松和特里斯坦-达库尼亚","SH"),
    KN("Saint Kitts and Nevis","圣基茨和尼维斯","KN"),
    LC("Saint Lucia","圣卢西亚","LC"),
    MF("Saint Martin (French part)","法属圣马丁","MF"),
    VC("Saint Vincent and the Grenadines","圣文森特和格林纳丁斯","VC"),
    WS("Samoa","萨摩亚","WS"),
    SM("San Marino","圣马力诺","SM"),
    ST("Sao Tome and Principe","圣多美和普林西比","ST"),
    SA("Saudi Arabia","沙特阿拉伯","SA"),
    SN("Senegal","塞内加尔","SN"),
    RS("Serbia","塞尔维亚","RS"),
    SC("Seychelles","塞舌尔","SC"),
    SL("Sierra Leone","塞拉利昂","SL"),
    SG("Singapore","新加坡","SG"),
    SX("Sint Maarten (Dutch part)","荷属圣马丁","SX"),
    SK("Slovakia","斯洛伐克","SK"),
    SI("Slovenia","斯洛文尼亚","SI"),
    SB("Solomon Islands","所罗门群岛","SB"),
    SO("Somalia","索马里","SO"),
    ZA("South Africa","南非","ZA"),
    GS("South Georgia and the South Sandwich Islands","南乔治亚和南桑威奇群岛","GS"),
    SS("South Sudan","南苏丹","SS"),
    ES("Spain","西班牙","ES"),
    LK("Sri Lanka","斯里兰卡","LK"),
    SD("Sudan","苏丹","SD"),
    SR("Suriname","苏里南","SR"),
    PM("Saint Pierre and Miquelon","圣皮埃尔和密克隆","PM"),
    SZ("Eswatini","斯威士兰","SZ"),
    SE("Sweden","瑞典","SE"),
    CH("Switzerland","瑞士","CH"),
    SY("Syrian Arab Republic","叙利亚","SY"),
    TJ("Tajikistan","塔吉克斯坦","TJ"),
    TZ("Tanzania, United Republic of","坦桑尼亚","TZ"),
    TH("Thailand","泰国","TH"),
    TL("Timor-Leste","东帝汶","TL"),
    TG("Togo","多哥","TG"),
    TK("Tokelau","托克劳","TK"),
    TO("Tonga","汤加","TO"),
    TT("Trinidad and Tobago","特立尼达和多巴哥","TT"),
    TN("Tunisia","突尼斯","TN"),
    TR("Türkiye","土耳其","TR"),
    TM("Turkmenistan","土库曼斯坦","TM"),
    TC("Turks and Caicos Islands","特克斯和凯科斯群岛","TC"),
    TV("Tuvalu","图瓦卢","TV"),
    UG("Uganda","乌干达","UG"),
    UA("Ukraine","乌克兰","UA"),
    AE("United Arab Emirates","阿联酋","AE"),
    GB("United Kingdom of Great Britain and Northern Ireland","英国","GB"),
    US("United States of America","美国","US"),
    UM("United States Minor Outlying Islands","美国本土外小岛屿","UM"),
    UY("Uruguay","乌拉圭","UY"),
    UZ("Uzbekistan","乌兹别克斯坦","UZ"),
    VU("Vanuatu","瓦努阿图","VU"),
    VE("Venezuela (Bolivarian Republic of)","委内瑞拉","VE"),
    VN("Viet Nam","越南","VN"),
    VI("Virgin Islands (U.S.)","美属维尔京群岛","VI"),
    WF("Wallis and Futuna","瓦利斯和富图纳","WF"),
    EH("Western Sahara","西撒哈拉","EH"),

    ;

    @EnumValue
    private final String enCountry;

    private final String country;

    private final String countryCode;


    @Override
    public String getCode() {
        return this.getCountry();
    }


    public static CountryCodeMappingEnum getByCountryCode(String countryCode) {
        if (StringUtils.isBlank(countryCode)) {
            return null;
        }
        for (CountryCodeMappingEnum value : CountryCodeMappingEnum.values()) {
            if (Objects.equals(value.getCountryCode(), countryCode)) {
                return value;
            }
        }
        return null;
    }
}
